package step_three;

public class erFen {
    public static void main(String[] args) {
//        二分查找
        int[] arr = new int[]{1, 2, 5, 9, 10, 23, 50, 88, 99, 101};

        System.out.println(test(arr, 88));

    }

    public static int test(int[] arr, int find) {
        int start = 0, end = arr.length - 1;
        while (start <= end) {
            int mid = (start + end + 1) / 2;
            if (find == arr[mid]) return mid;
            if (find < arr[mid]) end = mid - 1;
            if (find > arr[mid]) start = mid + 1;
        }
        return -1;
    }
}
